package com.sj.entity;

import com.baomidou.mybatisplus.annotation.*;

import java.io.Serializable;
import java.time.LocalDateTime;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
 * <p>
 * 点赞表
 * </p>
 *
 * @author 孙峻
 * @since 2022-03-09
 */
@Getter
@Setter
@Accessors(chain = true)
@ApiModel(value = "Praise对象", description = "点赞表")
public class Praise implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("点赞主键 自增长")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty("点赞文章类型 回复（answer） / 评论 （comment） / 文章（article）")
    private String giveType;

    @ApiModelProperty("点赞类型 1 赞 -1 踩")
    private Integer praiseType;

    @ApiModelProperty("文章id")
    private Integer articleId;

    @ApiModelProperty("评论id")
    private Integer commentId;

    @ApiModelProperty("回答id")
    private Integer answerId;

    @ApiModelProperty("用户id")
    private Integer userId;

    @ApiModelProperty("是否删除 1 删除 0 未删除")
    @TableLogic
    private Boolean del;

    @ApiModelProperty("创建时间")
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime createTime;

    @ApiModelProperty("更新时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime updateTime;

    public static PraiseBuilder builder() {
        return new PraiseBuilder();
    }

    public static final class PraiseBuilder {
        private Integer id;
        private String giveType;
        private Integer praiseType;
        private Integer articleId;
        private Integer userId;
        private Boolean del;
        private LocalDateTime createTime;
        private LocalDateTime updateTime;

        private PraiseBuilder() {
        }

        public PraiseBuilder id(Integer id) {
            this.id = id;
            return this;
        }

        public PraiseBuilder giveType(String giveType) {
            this.giveType = giveType;
            return this;
        }

        public PraiseBuilder praiseType(Integer praiseType) {
            this.praiseType = praiseType;
            return this;
        }

        public PraiseBuilder articleId(Integer articleId) {
            this.articleId = articleId;
            return this;
        }

        public PraiseBuilder userId(Integer userId) {
            this.userId = userId;
            return this;
        }

        public PraiseBuilder del(Boolean del) {
            this.del = del;
            return this;
        }

        public PraiseBuilder createTime(LocalDateTime createTime) {
            this.createTime = createTime;
            return this;
        }

        public PraiseBuilder updateTime(LocalDateTime updateTime) {
            this.updateTime = updateTime;
            return this;
        }

        public Praise build() {
            Praise praise = new Praise();
            praise.setId(id);
            praise.setGiveType(giveType);
            praise.setPraiseType(praiseType);
            praise.setArticleId(articleId);
            praise.setUserId(userId);
            praise.setDel(del);
            praise.setCreateTime(createTime);
            praise.setUpdateTime(updateTime);
            return praise;
        }
    }
}
